package com.zjxu.fair.home;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.zjxu.fair.R;

public class HomeFragment extends Fragment {
    public ConstraintLayout post;
    private Button bt1;
    private Button bt2;
    private Button bt3;

    public HomeFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {



        return inflater.inflate(R.layout.fragment_home, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        post = getActivity().findViewById(R.id.post_shangpin);
        bt1 = getActivity().findViewById(R.id.recommend_like);
        bt2 = getActivity().findViewById(R.id.recommend_time);
        bt3 = getActivity().findViewById(R.id.recommend_hot);
        // 发布商品
        post.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),PostCommodityActivity.class);
                startActivity(intent);
            }
        });

        // 商品瀑布流的转换
        bt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bt1.setTextSize(16);
                bt1.setTypeface(null, Typeface.BOLD);
                bt2.setTextSize(14);
                bt2.setTypeface(null, Typeface.NORMAL);
                bt3.setTextSize(14);
                bt3.setTypeface(null, Typeface.NORMAL);
                getActivity().findViewById(R.id.rv_recommend2).setVisibility(View.VISIBLE);
                getActivity().findViewById(R.id.rv_recommend3).setVisibility(View.VISIBLE);
            }
        });
        bt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bt1.setTextSize(14);
                bt1.setTypeface(null, Typeface.NORMAL);
                bt2.setTextSize(16);
                bt2.setTypeface(null, Typeface.BOLD);
                bt3.setTextSize(14);
                bt3.setTypeface(null, Typeface.NORMAL);
                getActivity().findViewById(R.id.rv_recommend2).setVisibility(View.INVISIBLE);
                getActivity().findViewById(R.id.rv_recommend3).setVisibility(View.INVISIBLE);
            }
        });
        bt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bt1.setTextSize(14);
                bt1.setTypeface(null, Typeface.NORMAL);
                bt2.setTextSize(14);
                bt2.setTypeface(null, Typeface.NORMAL);
                bt3.setTextSize(16);
                bt3.setTypeface(null, Typeface.BOLD);
                getActivity().findViewById(R.id.rv_recommend2).setVisibility(View.INVISIBLE);
                getActivity().findViewById(R.id.rv_recommend3).setVisibility(View.INVISIBLE);
            }
        });
    }
}